// src/router/index.js
import { Hide } from '@element-plus/icons-vue'
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
const Layout = () => import('@/layout/index.vue')
const Error = () => import('@/views/error/index.vue')

// 动态菜单
export const asyncRoutes = [
    {
        path: '/home',
        meta: {
            title: '首页',
        },
        icon: 'home-filled',
        component: Layout,
        children: [
            {
                path: '',
                name: 'home',
                meta: {
                    title: '首页',
                    affix: true,
                },
                component: () => import('@/views/Home/index.vue')
            }
        ],
    },
   
    // {
    //     path: '/Import',
    //     meta: {
    //         title: '导入文件',
    //     },        
    //     icon: 'document-add',
    //     component: Layout,
    //     children: [
    //         {
    //             path: '',
    //             name: 'import',
    //             meta: {
    //                 // title: '导入文件',
    //             },
    //             component: () => import('@/views/Import/index.vue')
    //         } 
    //     ]
    // },
    {
        path: '/filingCabinet',
        meta: {
            title: '档案柜管理',
        },
        component: Layout,
        icon: 'grid',
        children: [
            {
                path: '',
                name: 'filingCabinet',
                meta: {
                    title: '档案柜管理',
                },
                component: () => import('@/views/filingCabinet/index.vue')
            },
            {
                path: ':id',
                meta: {
                    title: '档案柜详情',
                },
                name: 'filingCabinetDetail',
                hidden: true,
                component: () => import('@/views/filingCabinet/detail.vue')
            },
            {
                path: 'boxdetail',
                name: 'boxDetail',
                meta: {
                    title: '档案盒详情',
                },
                hidden: true,
                component: () => import('@/views/filingCabinet/boxDetail.vue')
            }
        ]
    },
    {
        path: '/projectDigital',
        meta: {
            title: '项目数字化',
        },
        component: Layout,
        icon: 'folder',
        children:[
            {
                path: '',
                name: 'projectDigital',
                meta: {
                    title: '项目数字化',
                },
                component: () => import('@/views/projectDigital/index.vue')
            },
 
            {
                path: "addProject",
                name: "ProjectAdd",
                meta: {
                    title: "新建项目",
                },
                hidden: true,
                component: () => import('@/views/projectDigital/addProject.vue')
            },
            {
                path: "details",
                name: "ProjectDetails",
                meta: {
                    title: "项目详情",
                },
                hidden: true,
                component: () => import('@/views/projectDigital/details.vue')
            },
            {
                path: "highSpeedScanner",
                name:"highSpeedScanner",
                hidden: true,
                meta:{
                    title:"高拍仪"
                },
                component: () => import('@/views/projectDigital/highSpeedScanner.vue')

            },
        ]        
    },
    {
        path: '/Search', 
        meta: {
            title: '数据库搜索',
        },
        icon: 'search',
        component: Layout,
        children: [
            {
                path: '',
                name: 'Search', 
                meta: {
                    // title: '数据库搜索',
                },
                component: () => import('@/views/Search/index.vue')
            },
         
        ]
    },
    {
        path:"/Config",
        meta: {
            title: '配置管理',
        },
        component: Layout,
        icon: 'setting',
        children: [
            {
                path: '',
                name: 'config',
                meta: {
                    title: '配置管理',
                },
                component: () => import('@/views/Config/index.vue')
            },
        ]
    },
    {
        path:"/download",
        meta: {
            title: '下载中心',
        },
        component: Layout,
        icon:'download',
        children: [
            {
                path: '',
                name: 'download',
                meta: {
                    title: '下载中心',
                },
                component: () => import('@/views/Download/index.vue')
            }
        ]
    }
]
// 固定菜单
export const fixedRoutes = [
    { 
        path: '/', 
        redirect: '/home'
    },
    {
        path: '/Login',
        name: 'login',
        component: () => import('@/views/Login/index.vue')
    },
    {
        path: '/:pathMatch(.*)*',
        name: 'error-not-found',
        component: Error,
        meta: { title: '404' },
    },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    ...asyncRoutes,
    ...fixedRoutes
  ],
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { left: 0, top: 0 }
    }
  },
})

export default router
